import request from '@/utils/request'
// 获取地址列表
export const getAddressList = () => {
  return request.get('/address/list')
}

// 获取默认地址id
export const getDefaultAddrId = () => {
  return request.get('/address/defaultId')
}

// 获取省市区列表
export const getRegions = () => {
  return request.get('/region/tree')
}

// 添加收货地址
export const addPostAddress = (form) => {
  return request.post('/address/add', {
    form
  })
}
// 编辑收货地址
export const editPostAddress = (addressId, form) => {
  return request.post('/address/edit', {
    addressId,
    form
  })
}
// 设置默认地址
export const setDefaultAddress = (addressId) => {
  return request.post('/address/setDefault', {
    addressId
  })
}

//  编辑地址获取该地址详情
export const getDetailAddress = (addressId) => {
  return request.get('/address/detail', {
    params: {
      addressId
    }
  })
}
// 获取结算商品信息
export const checkOrder = (obj) => {
  return request.get('/checkout/order', {
    params: {
      delivery: 10,
      payType: 10,
      couponId: 0,
      isUsePoints: 0,
      remark: '',
      ...obj
    }
  })
}
// 提交订单
export const submitOrder = (mode, obj) => {
  return request.post('/checkout/submit', {
    mode,
    delivery: 10,
    payType: 10,
    couponId: 0,
    isUsePoints: 0,
    remark: '',
    ...obj
  })
}
